package console;

import checkers.Checkers;
import checkers.Move;
import java.util.ArrayList;

public class Main
{
    private final static int SIZE = 10;
    private final static int DEPTH = 12;
    private static Checkers check = new Checkers(SIZE);
    
    public static void main(String[] args)
    {
        int dest, start;
        int res = 0;
        
        while(res == 0)
        {
            System.out.println(check);
            if(check.whiteToPlay())
            {
                ArrayList<Move> moves;
                
                while(true)
                {
                    System.out.println("Enter starting square");
                    start = InputManager.getInt(1, (SIZE*SIZE)/2);
                    System.out.println("Enter destination square");
                    dest = InputManager.getInt(1, (SIZE*SIZE)/2);
                    moves = check.getPlayerMove(start, dest);
                    if(moves.isEmpty()) System.out.println("INVALID MOVE\n");
                    else break;
                }
                
                res = check.play(moves.get(0));
            }
            else res = check.play(check.getBestMoveAI(DEPTH));
        }
        
        System.out.println(check);
        
        switch(res)
        {
            case Checkers.WHITE_WIN: System.out.println("White wins"); break;
            case Checkers.BLACK_WIN: System.out.println("Black wins"); break;
            case Checkers.DRAW: System.out.println("Draw"); break;
        }
        
        InputManager.waitForKey();
    }
}
